Skip to content

Conversation

@Dethada
Copy link
Contributor

@Dethada Dethada commented Feb 9, 2025

  • Switched to use win api for both process creation and termination for all cases except spawning of whkd, as it will spawn a visible console window if we use win api for its process creation. I suspect this can be solved on whkd side but I'll leave it as is for now
  • Addresses [BUG]: komorebic stop --ahk doesn't stop autohotkey because of trailing space in command line #1174 now that we don't have powershell adding trailing space to the commandline
  • Startup time has a very noticeable improvement, on my machine it dropped from about 2s to < 1s
  • Modified error printing to print to stderr

whkd still remains to be spawned with powershell as switch to spawn directly will cause a console
window to pop up
The previous commits handles the trailing space issue, this commit concludes the fix by handling the
the termination of AHK processes with winapi. Note the added check for komorebic.ahk without the
quote, as this is new behavior that can happen when the provided path has no spaces, introduced
after swapping over to winapi

fix LGUG2Z#1174
@Dethada
Copy link
Contributor Author

Dethada commented Feb 9, 2025

@LGUG2Z please test if masir launches and closes without issue, I don't have it installed so I didn't test that

@Dethada
Copy link
Contributor Author

Dethada commented Feb 10, 2025

If this PR is merged into whkd, we can swap whkd spawning to winapi as well, I have tested that it works however one problem is that with that change the startup seems to be too fast. I think komorebi-bar is crashing on startup because komorebi is not ready yet. I have to implement a solution for that.

The other problem I noticed is suppose I have config setup for my komorebi-bar then each time I run komorebic start --bar then n more instances of komorebi-bar will be started, where n is the number of bars setup in my config.

Let's hold off on merging this until I have these problems fixed.

@Dethada
Copy link
Contributor Author

Dethada commented Feb 10, 2025

I have addressed the start up crash problem in the bar. The bar will now attempt to connect to komorebi at a 1s interval instead of crashing upon failure to connect.

Regarding this I will handle it in a separate PR after this PR is merged

The other problem I noticed is suppose I have config setup for my komorebi-bar then each time I run komorebic start --bar then n more instances of komorebi-bar will be started, where n is the number of bars setup in my config.

This PR is ready for review now, but depends on whkd pr, else a console window will appear when whkd is started with komorebic

@LGUG2Z
Copy link
Owner

LGUG2Z commented Feb 15, 2025

I'm going to park this PR until the 0.1.35 dev cycle

@LGUG2Z LGUG2Z force-pushed the master branch 4 times, most recently from efeefb7 to 974e5a2 Compare February 23, 2025 20:16
@LGUG2Z LGUG2Z force-pushed the master branch 8 times, most recently from 6926478 to 75a0506 Compare March 6, 2025 23:34
let state = serde_json::from_str::<komorebi_client::State>(&komorebi_client::send_query(
&SocketMessage::State,
)?)?;
let retry_duration = Duration::from_secs(1);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can retry in a loop here - we need to bail out if something isn't working to avoid spinning cycles and provide some form of user feedback that they can share when they open a support thread

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I don't think this is ideal. I had to make this change because the bars would now launch too fast, crashing as komorebi is yet ready to accept connections. If there is a way to know when komorebi has completed its startup and then we launch the bars that would be more ideal, but I don't know of a nice way of implementing that (simplest idea i have is using a tmp file to signal that startup is complete).

Some possible improvement I can think of

  • Wait for a specified duration in komorebic before launching the bars
  • Within the bar set a upper bound on the number of retries

But for both approaches finding the right duration/number of retries that caters to each user's machine might be tough.

What would be your approach to this problem?

@CtByte
Copy link
Contributor

CtByte commented Apr 8, 2025

@Dethada I just wanted to make a note here, that I've added more code that is related to this and probably needs to be changed, sorry.

@LGUG2Z
Copy link
Owner

LGUG2Z commented Apr 8, 2025

If there is a way to know when komorebi has completed its startup and then we launch the bars that would be more ideal, but I don't know of a nice way of implementing that (simplest idea i have is using a tmp file to signal that startup is complete).

Whoops, this got lost in my sea of GitHub notifications...

I typically use a successful exit code for komorebic state to signal when komorebi is considered "healthy" ie. can accept connections

I think in this case I would prefer to see this logic kept in komorebic, which is where all the orchestration is happening anyway - we should only attempt to launch the bars after we have validated in komorebic that komorebi is ready to accept subscription requests

@uhx
Copy link

uhx commented Jul 30, 2025

Hi @Dethada, please see LGUG2Z/whkd#87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants